package com.alpha.eceasy.mall.api.vo;

import com.alpha.eceasy.mall.api.entity.MallCommodity;
import com.alpha.eceasy.mall.api.entity.MallCommodityDetail;
import com.alpha.eceasy.mall.api.entity.MallCommoditySpecification;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.math.BigDecimal;
import java.util.List;
import java.util.Optional;

/**
 * @author huangpengfei
 */
@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
@Schema(description = "商品入参")
public class MallCommodityVO extends MallCommodity {
    @Schema(description = "主图轮播图")
    private String detailCover;
    @Schema(description = "主图视频")
    private String video;
    @Schema(description = "商品id")
    private String commodityGuid;
    @Schema(description = "详情图")
    private String content;
    @Schema(description = "说明图")
    private String instruction;
    @Schema(description =  "品类GuidList")
    private List<String> commodityCategoryGuidList;
    @Schema(description =  "品类名称List")
    private List<String> commodityCategoryNameList;
    @Schema(description =  "商品规格List")
    private List<MallCommoditySpecification> commoditySpecificationList;

    public MallCommodityVO(MallCommodity commodity, MallCommodityDetail commodityDetail) {
        Optional.ofNullable(commodityDetail).ifPresent(detail -> BeanUtils.copyProperties(detail, this));
        BeanUtils.copyProperties(commodity, this);
    }
}
